package com.xjm.ips.service;

import com.xjm.ips.entity.MyPage;
import com.xjm.ips.entity.Salary;
import com.xjm.ips.mapper.SalaryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SalaryService {
    @Autowired
    SalaryMapper salaryMapper;

    public MyPage getAllSalaries(Integer pageNo, Integer pageSize) {
        if(pageNo!=null && pageSize!=null){
            pageNo = (pageNo-1)*pageSize;
        }
        List<Salary> data = salaryMapper.getAllSalaries(pageNo,pageSize);
        Long total = salaryMapper.getTotal();
        MyPage myPage = new MyPage();
        myPage.setData(data);
        myPage.setTotal(total);
        return myPage;
    }

    public Integer addSalarySob(Salary salary) {
        salary.setCreateDate(new Date());
        return salaryMapper.insertSelective(salary);
    }

    public Integer updateSalarySob(Salary salary) {
        return salaryMapper.updateByPrimaryKeySelective(salary);
    }

    public Integer deleteSalarySob(Integer id) {
        return salaryMapper.deleteByPrimaryKey(id);
    }

    public Integer bitchDeleteSalarySob(Integer[] ids) {
          return salaryMapper.bitchDeleteSalarySob(ids);
    }
}
